package com.dyh.shardingJdbc.controller;

import com.dyh.shardingJdbc.entity.Order;
import com.dyh.shardingJdbc.entity.dto.InsertOrderDto;
import com.dyh.shardingJdbc.mapper.OrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author howl-xu
 * @version 1.0
 * Create by 2024/3/22
 */
@Slf4j
@RestController
@RequestMapping("/v1/sharding/")
public class OrderController {

    @Resource
    private OrderMapper orderMapper;

    @PostMapping("/insert")
    public void insertOrder(@RequestBody InsertOrderDto dto) {
        orderMapper.insertOrder(dto.getPrice(),dto.getUserId(),dto.getStatus());
    }

    @PostMapping("/select")
    public List<Order> selectOrder() {
        List<Order> list = orderMapper.selectOrderbyIds();
        return list;
    }
}
